<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">   
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <base target="_self"/>
    <title>添加站内消息</title>	
     <script type="text/javascript" charset="utf-8">
        window.UEDITOR_HOME_URL = "<%=path%>/ueditor/";
    </script>
    
	<script type="text/javascript" src="<%=request.getContextPath()%>/jqGrid/js/jquery-1.7.2.min.js"></script>
	<script type="text/javascript" charset="utf-8" src="<%=request.getContextPath()%>/ueditor/ueditor.config.js"></script>
   	<script type="text/javascript" charset="utf-8" src="<%=request.getContextPath()%>/ueditor/ueditor.all.min.js"> </script>
   	<!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
   	<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
   	<script type="text/javascript" charset="utf-8" src="<%=request.getContextPath()%>/ueditor/lang/zh-cn/zh-cn.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/jslib/mypage.js"></script>
	<script type="text/javascript" src="../jslib/jquery.validate.min.js"></script>
	<c:if test="${requestScope.msg!=null}">
			<script type="text/javascript">
	  	 		     alert('<c:out value="${requestScope.msg}"></c:out>');
	  	 		     window.close();
	  			</script>
		</c:if>
	<script type="text/javascript">
 function show(type){
	if(type==0){
		document.getElementById("showtr").style.display="none";
	}else if(type==1){
		document.getElementById("showtr").style.display="block";
	}
 }
 function selectUser(){
 	  var obj = new Object();
 	  obj.userIds = $("#tmUsersid").val();
 	  var jsons = window.showModalDialog("<%=request.getContextPath()%>/resource/choose/chooseAllUser.jsp?temp="+Math.round(Math.random()*10000),obj,"dialogWidth=923px;dialogHeight=450px;center:yes;resizable:yes;scroll:yes;status:no");
 	  if(typeof(jsons) == "undefined"){
			return false;
	  }
	  if (jsons!=null){
		var usernames = "";
		var userids = "";
		for(var i = 0;i<jsons.length;i++){
			var json = jsons[i];
			usernames += json.username+",";
			userids += json.userid+",";
		}
		if(usernames.length>0){
			usernames = usernames.substring(0,usernames.length-1);
			userids = userids.substring(0,userids.length-1);
		}
		$("#tmUsers").val(usernames);
		$("#tmUsersid").val(userids); 
	  }
 }
</script>   
  <style>
  html{   
    overflow-x: hidden; 
	} 
.td_label_zs {
   width: 200px;
   background-color: #FFFFFF;
   height: 20px;
}

.td_value_zs {
    text-align: left;
    background-color: #FFFFFF;
    height: 20px;
}
 
  </style>
    </head>
  
  <body >
  <center>
  <form class="fom" id="fom" method="post" action="sysmessage!addMessage.action" onsubmit="return checkform();" >
           <table style="width:900px;" >
           
                <tr>
                    <td colspan="4" style="background-color:#b7dbf3;text-align:center;height:20px;font-size:18px;font-weight:bold;">消息基本信息</td>
                </tr>
 
                <tr>
				    <td class="td_label_zs" align="left">消息标题：</td>
                    <td class="td_value_zs"  align="left"><input type="text" id="tmNoticeTitle" name="tmNoticeTitle" value="" style="width:400px" /></td>
                    <td class="td_label_zs" align="left">
                            <label for="username">消息类型：</label>
                        </td>
                        <td class="td_value_zs" align="left">
                            <select  name="tmNoticeType" id="tmNoticeType" style="width: 200px;" onchange="show(this.value)">
                                <option value="0" selected>系统公告</option>
                                <option value="1" >个人消息</option>                   
                            </select>   
                        </td> 
                </tr>    
                <tr style="display: none" id="showtr">
                      <td class="td_label_zs" align="left">通知人：</td>
                    <td class="td_value_zs" align="left" colspan="3">
                    <input type="hidden" id="tmUsersid" name="tmUsersid" value="" />
                    <input type="text"  style="width:400px" id="tmUsers" name="tmUsers" value="" />
                   <img src="<%=request.getContextPath() %>/web/images/form_icon_1.gif" style="cursor: hand" align="absmiddle"  onclick="selectUser();"></img>
                    <!-- 
                    	<img
							src="<%=request.getContextPath()%>/commission/images/accessories-magnifier.png"
							style="cursor: hand; vertical-align: middle;"
							onclick="selectUser();"></img>
                     -->
                    </td>
                </tr>  
				<tr>
                    <td class="td_value_zs" colspan="4">
                    <input name="tmNotice" id="tmNotice" type="hidden"/>
                     <script id="editor" type="text/plain" style="width:100%;height:300px;"></script>
                    </td>
                </tr>
				<tr>
                    <td colspan="4" align="center" style="background-color:#b7dbf3;text-align:center;height:20px;font-size:18px;font-weight:bold;">
						<span><input type="submit" value="保 存" class="button_b" /></span>
						<span><input type="button" value="关闭" class="button_b" onclick="window.close();" /></span>
					</td>
                </tr>
            </table>
        </form>
  </center>
  </body>
  
  <script type="text/javascript">
  //实例化编辑器
  //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
  UE.getEditor('editor');
 function checkform(){
	 $("#tmNotice").val(UE.getEditor('editor').getContent());
		if(jQuery.trim($("#tmNoticeTitle").val())==''){
			alert("标题不能为空！");
			return false;
		}
		
		var type = $("#tmNoticeType").val();
		if(type==1){
			if($("#tmUsersid").val()==''){
				alert("必须要选择用户！");
				return false;
			}
		}
		if(jQuery.trim($("#tmNotice").val())==''){
			alert("内容不能为空！");
			return false;
		}
	 }
</script>
</html>
